package com.myproject.filmrecommendationsys.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.myproject.filmrecommendationsys.domain.Film;
import com.myproject.filmrecommendationsys.service.IFilmService;
import com.myproject.filmrecommendationsys.util.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 影视Controller
 *
 * @author ruoyi
 * @date 2024-12-11
 */
@RestController
@RequestMapping("/film")
@Api(tags="影视管理")
public class FilmController
{
    @Autowired
    private IFilmService filmService;

    /**
     * 查询影视列表
     */

    @GetMapping("/list")
    @ApiOperation("查询影视列表")
    public AjaxResult list(Film film)
    {
        return AjaxResult.success(filmService.selectFilmList(film));
    }


    /**
     * 获取影视详细信息
     */

    @GetMapping(value = "/{id}")
    @ApiOperation("获取影视详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(filmService.selectFilmById(id));
    }

    /**
     * 新增影视
     */
    @PostMapping("/add")
    @ApiOperation("新增影视")
    public AjaxResult add(@RequestBody Film film)
    {
        return AjaxResult.success(filmService.insertFilm(film));
    }

    /**
     * 修改影视
     */
    @PutMapping("/update")
    @ApiOperation("修改影视")
    public AjaxResult edit(@RequestBody Film film)
    {
        return AjaxResult.success(filmService.updateFilm(film));
    }

    /**
     * 删除影视
     */

	@DeleteMapping("/{ids}")
    @ApiOperation("删除影视")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return AjaxResult.success(filmService.deleteFilmByIds(ids));
    }
}
